<!--
 * @Author: wangming
 * @Date: 2021-04-07 18:11:48
 * @LastEditors: wangming
 * @LastEditTime: 2022-05-05 18:15:21
 * @Description: 列表组件
-->
<template>
  <div class="box sz layoutbox p15 ks-col">
    <tableTitle
      :config="config"
      v-if="config.__config.tableTitle && config.__config.tableTitleContent"
    >
    </tableTitle>
    <tableHeader
      v-if="config.__config.searchStatus === 2"
      :column="config.__config.getSearchmodelList"
      :class="{ active: isAcitve('tb_h') }"
      :independentAdvancedSearch="config.__config.independentAdvancedSearch"
      :advancedSearchConfig="config.__config.advancedSearchConfig"
      @click.native.stop="handleAdd('tb_h')"
      @inClick="(v) => handleAdd('tb_h_i', v)"
      :activeId="getModelForm.code"
    ></tableHeader>
    <tableButtons
      :config="config"
      :class="{ active: config.hlcustomBtn.key === getModelForm.key }"
      @click.native.stop="
        handleAdd(config.hlcustomBtn.tagName, config.hlcustomBtn)
      "
    >
    </tableButtons>
    <hmTable
      :tablekey="config.key"
      :activeHeader="activeHeader"
      :setting="config.__config"
      :tableData="tableData"
      :column="config.__config.getEntitymodelList"
      :class="{ active: isAcitve('tb_lt') }"
      @click.native.stop="handleAdd('tb_lt')"
      @header-click="({ type, form }) => handleAdd(type, form)"
    >
    </hmTable>
    <div
      @click.stop="handleClick(config.hlChildConfig)"
      class="mt15 layoutbox p15 ovh"
      :class="{ active: config.hlChildConfig.key === getModelForm.key }"
    >
      <h3 v-if="config.hlChildConfig.__config.childTitle">
        {{
          $at(config.hlChildConfig.__config.childTitle_i18n) ||
          config.hlChildConfig.__config.childTitleContent ||
          "子表"
        }}
      </h3>
      <childTable
        v-show="!!config.hlChildConfig.__config.modelCode"
        :operate="hlChildTable.operate"
        :columnKey="getModelForm.key"
        :modelKey="config.hlChildConfig.__config.modelCode"
        class="mb10 layoutbox"
        :class="{ active: hlChildTable.key === getModelForm.key }"
        @handleAdd="handleClick"
        :config="hlChildTable"
        @header-click="handleClick"
      >
        <template v-slot:operate>
          <hmButton
            :type="i.buttonType"
            :key="i.composerKey"
            v-for="i in config.hlChildTable.operate.customBtn"
          >
            {{ i.label }}</hmButton
          >
          <div v-if="!config.hlChildTable.operate.customBtn.length" class="g9">
            子表操作
          </div>
        </template>
      </childTable>
      <div
        v-if="!config.hlChildConfig.__config.modelCode"
        class="tc g9 f20 p20"
      >
        请配置子表信息
      </div>
    </div>
    <div class="tr mt24" v-if="config.__config.pageStatus === 1">
      <x-pagination :total="total" />
    </div>
  </div>
</template>

<script>
import tablemixins from "./tablemixins";
import childTable from "./__components/childTable";
import hmButton from "../hlTableList/__components/button.jsx";
export default {
  created() {
    this.config.hlChildTable.key = "child_" + this.config.key;
    this.config.hlChildConfig.key = "childcof_" + this.config.key;
    this.config.hlChildTable.operate.key = "operate_" + this.config.key;
  },
  data() {
    return {
      tableData: [{}],
    };
  },
  components: { childTable, hmButton },
  mixins: [tablemixins],
  methods: {
    handleClick(value) {
      value.tableModelCode = this.config.__config.modelCode;
      value.isFormLayout = false;
      this.setModelForm(value);
    },
  },
  computed: {
    hlChildTable() {
      return this.config.hlChildTable;
    },
  },
};
</script>

<style lang="scss" scoped>
@import "./table.scss";
</style>
